/**
 * 
 */
package ar.edu.unicen.exa.oop.bbquery.model.forum;

import java.net.URI;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Transient;

/**
 * This user has a property that uses our sys and is stored in the db, it has
 * associed reports over a forum.
 * 
 * @author nicolas
 * 
 */

@Entity
public class BeanForumAuthToken implements ForumAuthToken {

	@Transient
	private Integer _id;
	@Transient
	private String _username;
	@Transient
	private String _password;
	@Transient
	private URI _forumRootURL;
	@Transient
	private String _forumTypeString;

	/*
	 * por ahora, vamos a poner una string para poner la impl, después hacemos
	 * el mecanismo automatico.
	 */
	/*
	 * @OneToMany(mappedBy="software")
	 * 
	 * @MapKey(name="codeName") HashMap<String, ReportDefinition> reports;
	 */
	/**
	 * Simple constructor
	 */

	BeanForumAuthToken() {
		this("", "", null, "");
	}

	BeanForumAuthToken(String user, String pwd, URI urlForum,
			String forum) {
		setUsername(user);
		setPassword(pwd);
		setForumRootURL(urlForum);
		setForumTypeString(forum);
	}

	/**
	 * @param username
	 *            the username to set
	 */
	@Override
	public void setUsername(String username) {
		this._username = username;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * ar.edu.unicen.exa.oop.bbquery.model.forum.ForumLoginToken#getUsername()
	 */
	@Override
	public String getUsername() {
		return _username;

	};

	/**
	 * @param password
	 *            the password to set
	 */

	@Override
	public void setPassword(String password) {
		this._password = password;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * ar.edu.unicen.exa.oop.bbquery.model.forum.ForumLoginToken#getPassword()
	 */
	@Override
	public String getPassword() {
		return _password;
	}

	/**
	 * @param forumURL
	 *            the forumURL to set
	 */
	@Override
	public void setForumRootURL(URI forumURL) {
		this._forumRootURL = forumURL;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * ar.edu.unicen.exa.oop.bbquery.model.forum.ForumLoginToken#getForumURL()
	 */
	@Override
	public URI getForumRootURL() {
		return _forumRootURL;
	}

	/**
	 * @param forumTypeString
	 *            the forumTypeString to set
	 */
	@Override
	public void setForumTypeString(String forumTypeString) {
		this._forumTypeString = forumTypeString;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * ar.edu.unicen.exa.oop.bbquery.model.forum.ForumLoginToken#getForumTypeString
	 * ()
	 */
	@Override
	public String getForumTypeString() {
		return _forumTypeString;
	}

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Override
	public Integer getId() {
		return _id;
	}

	/**
	 * @param id
	 *            the id to set
	 */
	@Override
	public void setId(Integer id) {
		this._id = id;
	}

	@Override
	public boolean equals(Object obj) {
		if (!(obj instanceof ForumAuthToken))
			return false;
		ForumAuthToken fat = (ForumAuthToken) obj;
		return this.getPassword() == fat.getPassword()
				&& this.getForumRootURL() == fat.getForumRootURL()
				&& this.getForumTypeString() == fat.getForumTypeString()
				&& this.getUsername() == fat.getUsername();
	}

}
